package com.xike.micromemberserver.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xike.entiy.ResultBean;
import com.xike.micromemberserver.entity.ChapterEntity;
import com.xike.micromemberserver.entity.NoteEntity;
import com.xike.micromemberserver.entity.PageInfoMation;
import com.xike.micromemberserver.service.NoteService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Note)表控制层
 *
 * @author wusong
 * @since 2021-05-09 11:55:55
 */
@ApiOperation("用户笔记")
@RestController
@RequestMapping("/member/note")
public class NoteController {
    /**
     * 服务对象
     */
    @Resource
    private NoteService noteService;

    /**
     * 通过主键查询单条数据
     *
     * @param
     * @return 单条数据
     */
    @ApiOperation("单挑数据")
    @PostMapping("/selectOne")
    public ResultBean selectOne(@RequestBody NoteEntity note) {
        NoteEntity noteEntity = noteService.queryById(note.getId());
        return ResultBean.builder().code(200).data(noteEntity).build();

    }
    @ApiOperation("新增一条笔记")
    @PostMapping("/addOneOne")
    public ResultBean addOneOne(@RequestBody NoteEntity note) {
        int state = noteService.insert(note);
        return  ResultBean.builder().code(200).msg("成功").build();

    }



    @ApiOperation("查询个人在某章的笔记")
    @PostMapping("/selectByCidAndUid")
    public ResultBean selectByCidAndUid(@RequestBody NoteEntity note) {
        List<NoteEntity> noteEntityList = noteService.selectByCidAndUid(note);
        return  ResultBean.builder().code(200).data(noteEntityList).build();


    }


}
